Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
detect-passive-events
Advanced tools
Readme
Detect if the browser supports passive event listeners.
Exports a reference to a singleton object (a micro state machine with an update function) with its state set to if the browser supports passive event listeners, as well as an update()
function which re-runs the tests and updates the object's state.
Note that the code used in the detection is adapted from this Passive Events Explainer.
detectPassiveEvents
micro state machineconst detectPassiveEvents = {
hasSupport: boolean,
// re-run the detection tests and update state
update() {...},
}
detect-passive-events
$ npm install detect-passive-events
detect-passive-events
import detectPassiveEvents from 'detect-passive-events';
// passive events are supported by the browser
if (detectPassiveEvents.hasSupport === true) {
// set listeners like this
document.addEventListener('scroll', handleScroll, { capture: false, passive: true });
}
// passive events are not supported by the browser
if (detectPassiveEvents.hasSupport === false) {
// set listeners like this
document.addEventListener('scroll', handleScroll, false);
}
// updating the state - most apps won't need to use this at all
detectPassiveEvents.update();
Note that the update()
function is run once at the time of import to set the object's initial state, and generally doesn't need to be run again. If it doesn't have access to the window
, then the state will be undefined
(detect-passive-events
will not throw an error), and you will need to call the update()
function manually at a later time to update its state.
detect-it
familydetect-it
detect-hover
detect-pointer
detect-touch-events
detect-passive-events
FAQs
Detect if the browser supports passive events
The npm package detect-passive-events receives a total of 196,257 weekly downloads. As such, detect-passive-events popularity was classified as popular.
We found that detect-passive-events demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.